package com.industriallogic.blackjack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Deck {

	private List<Card> cards = new ArrayList<Card>();
	
	public Deck(){
		populateDeck();
	}

	public void addCardsToDeck(Card card) {
		cards.add(card);
	}
	
	public List<Card> getCards() {
		return cards;
	}


	private void populateDeck() {
		
		for(Card.Rank rank : Card.Rank.values()) {
			addCardsToDeck(new Card(rank, Card.Suite.DIAMOND));
		}	
			

		for(Card.Rank rank : Card.Rank.values()) {
			addCardsToDeck(new Card(rank, Card.Suite.CLUB));
		}	

		for(Card.Rank rank : Card.Rank.values()) {
			addCardsToDeck(new Card(rank, Card.Suite.HEART));
		}	
		
		for(Card.Rank rank : Card.Rank.values()) {
			addCardsToDeck(new Card(rank, Card.Suite.SPADE));
		}	
			
		Collections.shuffle(cards);
	}


	public Card popCard() {
		Card card  = cards.get(0);
		cards.remove(0);
		return card;
	}

}